//
//  AXMyQbddTableViewCell.m
//  AnXin100
//
//  Created by 天质弘耕 on 2018/10/15.
//  Copyright © 2018年 tzhg. All rights reserved.
//

#import "AXMyQbddTableViewCell.h"
#import "UIView+SDAutoLayout.h"
#import "ZXCategories.h"
#import "UITableView+SDAutoTableViewCellHeight.h"

@interface AXMyQbddTableViewCell ()
/** 线 */
@property (nonatomic , strong) UIView *lineView;

@end

@implementation AXMyQbddTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self creatView];
        [self setlayout];
    }
    return self;
}

- (void)creatView {
    /** 店铺名 */
    self.storeNameLabel = [[UILabel alloc]init];
    self.storeNameLabel.textAlignment = NSTextAlignmentLeft;
    self.storeNameLabel.font = FONT_FOURTEEN;;
    self.storeNameLabel.textColor = COLOR_ORG;
    [self.contentView addSubview:self.storeNameLabel];
    /** 待付款 */
    self.dfkButton = [[UIButton alloc]init];
    self.dfkButton.titleLabel.font = FONT_FOURTEEN;;
    [self.dfkButton setTitle:@"待付款" forState:UIControlStateNormal];
    [self.dfkButton setTitleColor:COLOR_ORG forState:UIControlStateNormal];
    [self.contentView addSubview:self.dfkButton];
    /** 产品图片 */
    self.productImageView = [[UIImageView alloc]init];
    self.productImageView.contentMode =UIViewContentModeScaleAspectFill;
    self.productImageView.clipsToBounds=YES;//
    [self.contentView addSubview:self.productImageView];
    /** 产品名字 */
    self.productNameLabel = [[UILabel alloc]init];
    self.productNameLabel.font = FONT_FOURTEEN;;
    self.productNameLabel.numberOfLines = 2;
    self.productNameLabel.textColor = [UIColor colorWithHex:0x666666];
    [self.contentView addSubview:self.productNameLabel];
    /** 产品合计 */
    self.productCountLabel = [[UILabel alloc]init];
    self.productCountLabel.textColor = [UIColor colorWithHex:0x666666];
    self.productCountLabel.font = FONT_TWELVE;
    self.productCountLabel.text = @"共一件商品 合计 98（含运费10元）";
    [self.contentView addSubview:self.productCountLabel];
    /** 产品价格 */
    self.priceLabel = [[UILabel alloc]init];
    self.priceLabel.textColor = COLOR_ORG;
    self.priceLabel.font = FONT_EIGHTEEN;
    [self.contentView addSubview:self.priceLabel];
    /** 取消订单 */
    self.cancelButton = [[UIButton alloc]init];
    self.cancelButton.borderWidth = 1;
    self.cancelButton.borderColor = [UIColor colorWithHex:0x666666];
    self.cancelButton.cornerRadius = 2;
    self.cancelButton.titleLabel.font = FONT_FOURTEEN;;
    [self.cancelButton setTitle:@"取消订单" forState:UIControlStateNormal];
    [self.cancelButton setTitleColor:[UIColor colorWithHex:0x666666] forState:UIControlStateNormal];
    [self.contentView addSubview:self.cancelButton];
    /** 去支付*/
    self.payButton = [[UIButton alloc]init];
    self.payButton.titleLabel.font = FONT_FOURTEEN;;
    self.payButton.backgroundColor = COLOR_ORG;
    [self.payButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [self.payButton setTitle:@"去支付" forState:UIControlStateNormal];
    [self.contentView addSubview:self.payButton];
    
    if (SCREEN_WIDTH <= 320) {
        self.productNameLabel.font = FONT_TWELVE;
        self.productCountLabel.font = FONT_TWELVE;
        self.priceLabel.font = FONT_TWELVE;
        self.cancelButton.titleLabel.font = [UIFont systemFontOfSize:10];
        self.payButton.titleLabel.font = FONT_TWELVE;
    }
    
    self.lineView = [[UIView alloc]init];
    self.lineView.backgroundColor = [UIColor groupTableViewBackgroundColor];
    [self.contentView addSubview:self.lineView];
    
    
    
}

- (void)setlayout {
    /** 店铺名称 */
    self.storeNameLabel.sd_layout
    .leftSpaceToView(self.contentView, 10)
    .topSpaceToView(self.contentView, 0)
    .widthIs(SCREEN_WIDTH-100)
    .heightIs(30);
    /** 待付款 */
    self.dfkButton.sd_layout
    .rightSpaceToView(self.contentView, 10)
    .topSpaceToView(self.contentView, 0)
    .widthIs(70)
    .heightIs(30);
    /* 产品图片 **/
    self.productImageView.sd_layout
    .leftSpaceToView(self.contentView, 10)
    .topSpaceToView(self.dfkButton, 0)
    .widthIs(100)
    .heightIs(100);
    /** 产品名字 */
    self.productNameLabel.sd_layout
    .leftSpaceToView(self.productImageView, 10)
    .topSpaceToView(self.dfkButton, 0)
    .rightSpaceToView(self.contentView, 10)
    .heightIs(40);
    /* 产品合计 **/
    self.productCountLabel.sd_layout
    .leftEqualToView(self.productNameLabel)
    .rightSpaceToView(self.contentView, 10)
    .topSpaceToView(self.productNameLabel, 0)
    .heightIs(30);
    /* 价格 **/
    self.priceLabel.sd_layout
    .leftSpaceToView(self.productImageView, 10)
    .topSpaceToView(self.productCountLabel, 0)
    .widthIs(50)
    .heightIs(30);
    /** 去支付按钮 */
    self.payButton.sd_layout
    .rightSpaceToView(self.contentView, 10)
    .topSpaceToView(self.productCountLabel, 0)
    .widthIs(100)
    .heightIs(30);
    /** 取消按钮 */
    self.cancelButton.sd_layout
    .rightSpaceToView(self.payButton, 10)
    .topSpaceToView(self.productCountLabel, 0)
    .widthIs(100)
    .heightIs(30);
    
    if (SCREEN_WIDTH <= 320 ) {
        /* 价格 **/
        self.priceLabel.sd_layout
        .leftSpaceToView(self.productImageView, 10)
        .topSpaceToView(self.productCountLabel, 0)
        .widthIs(30)
        .heightIs(30);
        /** 去支付按钮 */
        self.payButton.sd_layout
        .rightSpaceToView(self.contentView, 10)
        .topSpaceToView(self.productCountLabel, 0)
        .widthIs(50)
        .heightIs(30);
        /** 取消按钮 */
        self.cancelButton.sd_layout
        .rightSpaceToView(self.payButton, 10)
        .topSpaceToView(self.productCountLabel, 0)
        .widthIs(50)
        .heightIs(30);
    }
    
   
    self.lineView.sd_layout
    .rightSpaceToView(self.contentView, 0)
    .topSpaceToView(self.cancelButton, 10)
    .widthIs(SCREEN_WIDTH)
    .heightIs(10);
    
    
    /** cell高度自适应第一步 */
    [self setupAutoHeightWithBottomView:self.lineView bottomMargin:10];
    
}

@end

